<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('复诊列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <input type="hidden" id="patDiaId" name="patDiaId" th:value="${dia}">
                            <input type="hidden" id="admType" name="admType" th:value="${admType}">
                            <li>
                                <label>复诊状态：</label>
                                <select name="admStatus" >
                                    <option value="">所有</option>
                                    <option value="Y">已复诊</option>
                                    <option value="N">未复诊</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <a class="btn btn-primary  " onclick="updateBatch('Y')" shiro:hasPermission="disease:adm:edit">
                    <i class="fa fa-edit"></i> 标记已复诊
                </a>
                <a class="btn btn-danger  " onclick="updateBatch('N')" shiro:hasPermission="disease:adm:edit">
                    <i class="fa fa-edit"></i> 标记未复诊
                </a>
                <a class="btn btn-primary" onclick="updateAll('Y')" shiro:hasPermission="disease:adm:edit">
                    <i class="fa fa-plus"></i> 全部已复诊
                </a>
                <a class="btn btn-danger" onclick="updateAll('N')" shiro:hasPermission="disease:adm:edit">
                    <i class="fa fa-plus"></i> 全部未复诊
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="disease:adm:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="disease:adm:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('disease:adm:edit')}]];
        var removeFlag = [[${@permission.hasPermi('disease:adm:remove')}]];
        var prefix = ctx + "disease/adm";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: ctx + "disease/adminfo/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "复诊",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'admId',
                    visible: false
                },
                {
                    field: 'patId',
                    visible: false
                },
                {
                    field: 'patName',
                    title: '患者姓名'
                },
                {
                    field: 'patTel',
                    title: '电话'
                },
                {
                    field: 'patContact',
                    title: '联系人'
                },                {
                    field: 'patContactTel',
                    title: '联系人电话'
                },
                {
                    field: 'admDate',
                    title: '复诊日期'
                },
                {
                    field: 'timeInterval',
                    title: '间隔时间'
                },
                {
                    field: 'admStatus',
                    title: '复诊状态',
                    formatter: function(value, row, index) {
                        if("Y"==value){
                            return "<span class='badge badge-primary'>已复诊</span>"
                        }else{
                            return "<span class='badge badge-danger'>未复诊</span>"
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateY(\'' + row.admId + '\')"><i class="fa fa-edit"></i>已复诊</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateN(\'' + row.admId + '\')"><i class="fa fa-edit"></i>未复诊</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.admId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.admId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function updateY(adm){
            update(adm,"Y","")
        }
        function updateN(adm){
            update(adm,"N","")
        }
        function updateBatch(status){
            var rows =$.table.selectColumns("admId")
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            update(rows.join(),status,"")
        }
        function updateAll(status){
            update("",status,"Y")
        }
        function update(ids,status,flag){
            $.operate.postJson(ctx + "disease/adm/edit",JSON.stringify({
                "ids":ids,
                "status":status,
                "allFlag":flag
            }))
        }
    </script>
</body>
</html>